<template>
	<view class="forget">
		
		<view class="content">
			<!-- 主体 -->
			<view class="main">
				<wInput
					v-model="value"
					maxlength="11"
					:placeholder="placeholder"
					isShowPass
				></wInput>
			</view>
			
			<wButton 
				text="保存"
				:rotate="isRotate" 
				@click.native="startRePass()"
			></wButton>

		</view>
	</view>
</template>

<script>
	import {  
		mapActions
	} from 'vuex';  
	var _this;
	import wInput from '@/components/watch-login/watch-input.vue' //input
	import wButton from '@/components/watch-login/watch-button.vue' //button
	export default {
		data() {
			return {
				value: '',
				isRotate: false, //是否加载旋转
				placeholder: '请输入真实姓名',
				type: 'userName'
			}
		},
		components:{
			wInput,
			wButton
		},
		mounted() {
			_this= this;
		},
		methods: {
			startRePass() {
				//重置密码
				if(this.isRotate){
					//判断是否加载中，避免重复点击请求
					return false;
				}
				 uni.showToast({
				    icon: 'none',
					position: 'bottom',
				    title: '保存成功'
				});
				_this.isRotate=true
				const data= {};
				_this.isRotate=false
				this.reviseInfo({key: this.type, value: this.value})
				this.$forceUpdate();
				uni.navigateBack()
			},
			...mapActions({
				reviseInfo: 'REVISE_INFO'
			})
		},
		onLoad(options){
			if (options.type === 'nickname') {
				this.type = 'nickname'
			} else if (options.type === 'qq') {
				this.type = 'qq'
			} else if (options.type === 'email') {
				this.type = 'email'
			} else if (options.type === 'wechat') {
				this.type = 'wechat'
			}
			if (options.data) {
				this.placeholder = options.data
			} else if (options.type === 'nickname') {
				this.placeholder = '请输入您的昵称'
			} else if (options.type === 'qq') {
				this.placeholder = '请输入您的QQ号'
			} else if (options.type === 'email') {
				this.placeholder = '请输入您的邮箱'
			} else if (options.type === 'wechat') {
				this.placeholder = '请输入您的微信号'
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("../../../components/watch-login/css/icon.css");
	/* 主体 */
	.content {
		display: flex;
		flex-direction: column;
		justify-content:center;
		/* margin-top: 128upx; */
	}
	.main {
		display: flex;
		flex-direction: column;
		padding-left: 70upx;
		padding-right: 70upx;
	}
	.tips {
		color: #999999;
		font-size: 28upx;
		margin-top: 64upx;
		margin-left: 48upx;
	}
</style>

